#[macro_use] extern crate rocket;

use std::net::IpAddr;

#[get("/get_ip")]
fn hello(client_ip: Option<IpAddr>) -> String {
    let ip = match client_ip {  
        Some(ip) => format!("Your IP address is: {}", ip),  
        None => "No IP address provided".to_string(),  
    } ;
    format!("Hello, {}", ip)
}

#[launch]
fn rocket() -> _ {
    // 运行export ROCKET_PORT=8089 来设置监听端口号
    rocket::build().mount("/", routes![hello])
}
